package com.gitee.xhs.sampleRecod.transactionRecord;

import cn.hutool.core.date.DateUtil;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * @author BigHead
 * @date 2022/6/28 16:52
 * @description 简单推送对象
 */
public class Transaction implements Serializable {

    private String streamName;

    private int taskIndexNum;

    private long accountId;

    private long timestamp;

    private double amount;

    private int dataNum;

    public Transaction() {
    }

    public Transaction(long accountId, long timestamp, double amount) {
        this.accountId = accountId;
        this.timestamp = timestamp;
        this.amount = amount;
    }

    public String getStreamName() {
        return streamName;
    }

    public void setStreamName(String streamName) {
        this.streamName = streamName;
    }

    public int getTaskIndexNum() {
        return taskIndexNum;
    }

    public void setTaskIndexNum(int taskIndexNum) {
        this.taskIndexNum = taskIndexNum;
    }

    public long getAccountId() {
        return accountId;
    }

    public void setAccountId(long id) {
        this.accountId = id;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public int getDataNum() {
        return dataNum;
    }

    public void setDataNum(int dataNum) {
        this.dataNum = dataNum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Transaction that = (Transaction) o;
        return taskIndexNum == that.taskIndexNum && accountId == that.accountId && Double.compare(that.amount, amount) == 0 && dataNum == that.dataNum;
    }

    @Override
    public int hashCode() {
        return Objects.hash(taskIndexNum, accountId, amount, dataNum);
    }

    @Override
    public String toString() {
        return "Transaction{" +
                "streamName='" + streamName + '\'' +
                ", taskIndexNum=" + taskIndexNum +
                ", accountId=" + accountId +
                ", timestamp=" + timestamp +
                ", timestampString=" + DateUtil.formatDateTime(new Date(timestamp)) +
                ", amount=" + amount +
                ", dataNum=" + dataNum +
                '}';
    }

}
